package be.wiim.rpi;

import com.pi4j.io.serial.Serial;
import com.pi4j.io.serial.SerialDataEvent;
import com.pi4j.io.serial.SerialDataListener;
import com.pi4j.io.serial.SerialFactory;
import com.pi4j.io.serial.SerialPortException;
import java.util.Date;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author wimvandecasteele
 */
public class GPS {

    public GPS() throws InterruptedException {
        final Serial serial = SerialFactory.createInstance();

        serial.addListener(new SerialDataListener() {
            @Override
            public void dataReceived(SerialDataEvent event) {
                System.out.print("RxD: "+ event.getData());
            }
        });
                
        try {
            serial.open(Serial.DEFAULT_COM_PORT, 4800);
            }
            catch(IllegalStateException ex){
                ex.printStackTrace();                    
            }
                
                // wait 1 second before continuing
                Thread.sleep(1000);
    }
       
}
